package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.distributor.dto.OrderDeleteBatchDTO;
import com.xbongbong.distributor.vo.OrderDeleteBatchVO;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.pojo.vo.AfterSaveVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.pro.applist.pojo.vo.ListAppVO;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.businessdata.pojo.dto.OrderReviewDTO;
import com.xbongbong.pro.businessproduct.pojo.dto.BusinessProductListDTO;
import com.xbongbong.pro.businesstage.pojo.dto.StageLogListDTO;
import com.xbongbong.pro.businesstage.pojo.vo.StageLogListVO;
import com.xbongbong.pro.detailtab.dto.ChangeDocumentStatusSaveDTO;
import com.xbongbong.pro.detailtab.vo.ChangeDocumentStatusSaveVO;
import com.xbongbong.pro.detailtab.vo.ProductSummaryVO;
import com.xbongbong.pro.formdata.pojo.dto.SaasAnalysisDataDTO;
import com.xbongbong.pro.formexplain.pojo.dto.HandlerExplainInLinkItemDTO;
import com.xbongbong.saas.domain.entity.ext.ContractEntityExt;

import java.util.List;

/**
 * 订货单service处理层
 */
public interface OrderService {

    /**
     * 订货单保存前校验
     * @param validateDataDTO
     * @throws XbbException
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 订货单保存后逻辑
     * @param saasFormSaveDTO
     * @throws XbbException
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-22 14:55
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 获取订单进度条
     * @return
     */
    StageLogListVO getAllStageArray(StageLogListDTO stageLogListDTO) throws XbbException;

    /**
     * 订货单审核
     * @param orderReviewDTO
     * @return com.xbongbong.paas.pojo.vo.AfterSaveVO
     * @throws XbbException
     * @since v1.0
     * @version v1.0
     * @update
     */
    AfterSaveVO orderReview(OrderReviewDTO orderReviewDTO) throws XbbException;

    /**
     * 项目日志
     * @param saasFormSaveDTO
     * @param creatorId
     * @param newCustomerId
     * @param communicateMemo
     * @param subType
     * @param log
     */
    void projectLog(SaasFormSaveDTO saasFormSaveDTO, String creatorId, Long newCustomerId, String communicateMemo, Integer subType, String log);

    /**
     * 更新订货单开启关闭状态
     * @param changeDocumentStatusSaveDTO
     * @return
     */
    ChangeDocumentStatusSaveVO changeDocumentStatus(ChangeDocumentStatusSaveDTO changeDocumentStatusSaveDTO) throws XbbException;

    /**
     * 格式化移动端列表页
     *
     * @param formDataListDTO 用户
     * @param esEntities 业务实体集合
     * @param totalCount 总数
     * @return ListAppVO
     * @throws XbbException
     * @author long.rao
     * @date 2019-03-11 13:50
     */
    ListAppVO formatOrderAppList(FormDataListDTO formDataListDTO, List<PaasFormDataEntityExt> esEntities, Integer totalCount) throws XbbException;
    /**
     * 关联新建时格式化解释
     *
     * @param handlerExplainInLinkItemDTO 入参
     * @throws XbbException 异常
     * @author long.rao
     * @date 2019-02-22 14:55
     */
    void formatLinkAddExplain(HandlerExplainInLinkItemDTO handlerExplainInLinkItemDTO) throws XbbException;

    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;


    /**
     * 汇总订货单产品信息（详情页，几种产品几件）
     *
     * @param businessProductListDTO
     * @return com.xbongbong.pro.detailtab.vo.ProductSummaryVO
     * @throws XbbException
     * @author xinpeng.jiang
     * @date 2021/1/25 16:14
     * @version 1.0
     */
    ProductSummaryVO summaryProductList(BusinessProductListDTO businessProductListDTO) throws XbbException;

    /**
     * 批量删除
     * @param orderDeleteBatchDTO
     * @return
     * @throws XbbException
     */
    OrderDeleteBatchVO deleteBatch(OrderDeleteBatchDTO orderDeleteBatchDTO) throws XbbException;

    /**
     * 订货单状态变更消息推送
     * @param contractEntityExt
     * @param oldStatus
     * @param newStatus
     * @param corpid
     * @param baseDTO
     */
    void pushMessageChangeStatus(ContractEntityExt contractEntityExt, String oldStatus, String newStatus, String corpid, BaseDTO baseDTO);
}
